RetroMission *** CD-ROM | disk | FTP | web | AOL | usenet | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / reader_requests / cheatcodes / .install / marblemadness / mmpatch.c (.txt) next >
C/C++ Source or Header  |  2000-02-23  |  3KB  |  105 lines

  1. /*
  2.  * Patch Marble Madness.
  3.  *
  4.  * Usage: cd <Marble Madness disk>
  5.  *        mmpatch
  6.  *
  7.  * > removes protection on c/xxx, c/zzz, c/MarbleMadness!.dat
  8.  *   - 2.0+ actually checks for read protection
  9.  *
  10.  * > applies standard patch to c/xxx (taken from QuickCopy)
  11.  *   - changes some conditional branches to unconditional
  12.  *   - inserts some immediate constants
  13.  *   
  14.  * > applies patch to c/zzz
  15.  *   - original reads some values from low memory and from the Task struct,
  16.  *     expecting the third nybble to be 0xFC (i.e., pointers into ROM);
  17.  *     512k ROMs are at 0xF8xxxx, so this no longer works
  18.  *   - patch uses immediate values instead
  19.  *
  20.  * Derek Noonburg
  21.  * derekn@ece.cmu.edu
  22.  * 29-April-93
  23.  */
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <exec/types.h>
  28. #include <dos/dos.h>
  29. #include <proto/dos.h>
  30.  
  31. #define XXXNAME "c/xxx"
  32. #define ZZZNAME "c/zzz"
  33. #define DATNAME "c/MarbleMadness!.dat"
  34. #define SIGNAME "c/sigfile"
  35. #define XXXLEN 6116
  36. #define ZZZLEN 4948
  37.  
  38. int
  39. main()
  40. {
  41.     BPTR f;
  42.     static UBYTE buf[XXXLEN];
  43.     UWORD *wbuf = (UWORD *)buf;
  44.  
  45.     SetProtection(XXXNAME, 0);
  46.     SetProtection(ZZZNAME, 0);
  47.     SetProtection(DATNAME, 0);
  48.     SetProtection(SIGNAME, 0);
  49.  
  50.     if (!(f = Open(XXXNAME, MODE_OLDFILE))) {
  51.         fprintf(stderr, "Can't open file\n");
  52.         exit(1);
  53.     }
  54.     Read(f, buf, XXXLEN);
  55.     buf[0x1bc] = 0x25;
  56.     buf[0x1c0] = 0x9b;
  57.     buf[0x1c4] = 0x6e;
  58.     buf[0x1c6] = 0x83;
  59.     buf[0x1c7] = 0x78;
  60.     buf[0x336] = 0x40;
  61.     buf[0x337] = 0xad;
  62.     buf[0x386] = 0xaf;
  63.     buf[0x387] = 0x3e;
  64.     buf[0x38b] = 0x43;
  65.     buf[0x38e] = 0x53;
  66.     buf[0x38f] = 0xb1;
  67.     Seek(f, 0, OFFSET_BEGINNING);
  68.     Write(f, buf, XXXLEN);
  69.     Close(f);
  70.  
  71.     if (!(f = Open(ZZZNAME, MODE_OLDFILE))) {
  72.         fprintf(stderr, "Can't open file\n");
  73.         exit(1);
  74.     }
  75.     Read(f, buf, ZZZLEN);
  76.     wbuf[0x82a] = 0x2f3c;   /* move.l #fc000000,-(a7) */
  77.     wbuf[0x82b] = 0x00fc;
  78.     wbuf[0x82c] = 0x0000;
  79.     wbuf[0x82d] = 0x4e71;   /* nop */
  80.     wbuf[0x82e] = 0x4e71;   /* nop */
  81.     wbuf[0x82f] = 0x4e71;   /* nop */
  82.     wbuf[0x830] = 0x4e71;   /* nop */
  83.     wbuf[0x848] = 0x2f3c;   /* move.l #fc000000,-(a7) */
  84.     wbuf[0x849] = 0x00fc;
  85.     wbuf[0x84a] = 0x0000;
  86.     wbuf[0x84b] = 0x4e71;   /* nop */
  87.     wbuf[0x864] = 0x2f3c;   /* move.l #fc000000,-(a7) */
  88.     wbuf[0x865] = 0x00fc;
  89.     wbuf[0x866] = 0x0000;
  90.     wbuf[0x867] = 0x4e71;   /* nop */
  91.     wbuf[0x873] = 0x2f3c;   /* move.l #fc000000,-(a7) */
  92.     wbuf[0x874] = 0x00fc;
  93.     wbuf[0x875] = 0x0000;
  94.     wbuf[0x876] = 0x4e71;   /* nop */
  95.     wbuf[0x87e] = 0x2f3c;   /* move.l #fc000000,-(a7) */
  96.     wbuf[0x87f] = 0x00fc;
  97.     wbuf[0x880] = 0x0000;
  98.     wbuf[0x881] = 0x4e71;   /* nop */
  99.     Seek(f, 0, OFFSET_BEGINNING);
  100.     Write(f, buf, ZZZLEN);
  101.     Close(f);
  102.  
  103.     return 0;
  104. }
  105.